package cn.edu.answer.service.impl;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.edu.answer.dao.StudentDao;
import cn.edu.answer.po.Student;
import cn.edu.answer.service.StudentService;
import cn.edu.answer.utils.Page;




/**
 * 学生管理
 */
@Service("studentService")
@Transactional
public class StudentServiceImpl implements StudentService {
	// 声明DAO属性并注入
	@Autowired
	private StudentDao studentDao;
	// 学生信息列表
	public Page<Student> findStudentList(Integer page, Integer rows) {
		// 创建学生对象
		Student student = new Student();

		// 当前页
		student.setStart((page-1) * rows) ;
		// 每页数
		student.setRows(rows);
		// 查询学生列表
		List<Student> students = 
                            studentDao.selectStudentList(student);
		// 查询学生列表总记录数
		Integer count = studentDao.selectStudentListCount(student);
		// 创建Page返回对象
		Page<Student> result = new Page<>();
		result.setPage(page);
		result.setRows(students);
		result.setSize(rows);
		result.setTotal(count);
		return result;
	}
	@Override
	public int createStudent(Student student) {
		// TODO Auto-generated method stub
		return studentDao.createStudent(student);
	}
	@Override
	public int deleteStudent(String sno) {
		// TODO Auto-generated method stub
		return studentDao.deleteStudent(sno);
	}
	
	@Override
	public List<Student> getStudentList(String item) {
		// TODO Auto-generated method stub
		return studentDao.getStudentList(item);
	}
	
	
	
}
